﻿
using System.Security.Claims;

namespace Admin.NET.Core;
public static class UserContext
{
    public static ClaimsPrincipal Default { get; private set; }
    static UserContext()
    {
        // 初始化默认用户（可根据需要修改默认值）
        Default = CreateDefaultUser();
    }

    /// <summary>
    /// 创建默认用户（用于匿名访问场景）
    /// </summary>
    private static ClaimsPrincipal CreateDefaultUser()
    {
        var identity = new ClaimsIdentity("DefaultUser");
        identity.AddClaim(new Claim(ClaimConst.UserId, "1300000000101"));
        identity.AddClaim(new Claim(ClaimConst.RealName, "系统默认用户"));
        // 添加其他必要的 Claim（如 TenantId、OrgId 等）
        identity.AddClaim(new Claim(ClaimConst.TenantId, "1300000000001"));
        //identity.AddClaim(new Claim(ClaimConst.OrgId, "0"));

        return new ClaimsPrincipal(identity);
    }
}